<?php
namespace app\api\model;



class Category extends Base
{
    // 设置查询时需要隐藏不显示的字段
    protected $hidden = ['delete_time', 'update_time'];

    /**
     * 获取对应的image信息
     * @return \think\model\relation\BelongsTo
     */
    public function img()
    {
        return self::belongsTo('Image', 'topic_img_id', 'id');
    }

    /**
     * 获取所有分类列表
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getAllCategory()
    {
        return self::with('img')->select();
    }
}


